{% extends "./base.html" %}
{% block title %}Add New Item{% endblock %}
{% block content %}
{% if returnto -%}
	<a class="btn btn-primary" href={{ returnto }}>Return to previous page</a>
{%- endif %}
<table id="item">
	<tbody>
		<tr class="table">
			<td class="span3" rowspan="3">
				<a href="{{ uri.addParams(action='upload') }}">
				{% if item.photo %}
				<img src="{{ uri.absPath('serve', item.photo.key()) }}" alt="{{ item.title }} by {{ item.seller_obj.getName() }} at {{ item.price }}">
				{% else %}
				<img src="http://placehold.it/255x255" alt="{{ item.title }} by {{ item.seller_obj.getName() }} at {{ item.price }}">
				{% endif %}
				</a>
			</td>
			<td class="span3"> <h3>{{ item.title }} </h3></td>
			{% if item.canEdit(user) %}
			<td class="span3"> <h5> Expires: <br />{{ item.pretty_expired() }} </h5></td>
			{% else %}
			<td class="span3"> </td>
			{% endif %}
			<td class="span3"> <h5> Price: {{ item.pretty_price() }}  </h5> <a class="btn btn-primary" href="{{ uri.absPath('messages').addParams(recipient=item.seller_obj.key().id()) }}">Contact {{ item.seller_obj.getName() }}</a></td>
		</tr>
		<tr>
			<td colspan="3"> <h6>{{ item.desc }} </h6></td>
		</tr>
		<tr><td colspan="3">
			{% if item.canEdit(user) %}
			<a class="btn btn-primary" href="{{ uri.addParams(action='edit') }}">Edit</a>
			<form action="" method="post" style="display:inline">
				<input type="hidden" name="action" value="delete" />
				<input class="btn btn-primary" type="submit" value="Delete" />
			</form>
			{% if item.isActive() %}
			<form action="" method="post" style="display:inline">
				<input type="hidden" name="action" value="deactivate" />
				<input class="btn btn-primary" type="submit" value="Deactivate" />
			</form>
			{% else %}
			<form action="" method="post" style="display:inline">
				<input type="hidden" name="action" value="activate" />
				<input class="btn btn-primary" type="submit" value="Activate" />
			</form>
			{% endif %}
			{% endif %}
		</td></tr>
	</tbody>
</table>

{% endblock %}
